home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
c_text.zip
/
CPBLK.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-06-10
|
6KB
|
139 lines
;****** CPBLK *****************************************************************
;
; Copy a screen buffer to display memory without visual "noise"
; (C) 1982, 1986 Omniware
;
; Usage:
; cpblk(src_os, src_seg, dest_os, dest_seg);
; unsigned src_os, src_seg, dest_os, dest_seg;
;
; Notes:
; 1. Uses calling conventions selected by an equate.
; 2. Provides the copy function solely for the c/g adapter. Test
; for the required hardware before calling this function.
; 3. The segments and offsets given in the calling program
; determine whether this function does a screen save or a
; screen update operation.
;*****************************************************************************
@ab equ 4 ;small model only
a1 equ @ab
a2 equ @ab+4
;-----------video status information-------------
VSTAT equ 3dah ; video (CRT) status register
HRTRCE equ 1 ; horizontal retrace bit mask
VRTRCE equ 8 ; vertical retrace bit mask
;-----block data (these values result in 8 extra bytes being copied)----
BLKCNT equ 6 ; no. of buffer blocks to copy
WRDCNT1 equ 240 ; no. of words to copy during ver. retrace
WRDCNT2 equ 94 ; no. of words to copy during raster scan
BYTECNT equ 2 * WRDCNT2 ; no. of bytes to copy during raster scan
assume cs:_TEXT
_TEXT segment byte public 'CODE'
public _cpblk
_cpblk proc near
;-------save registers and flags-----------
push bp
mov bp,sp
push di ; di and si saved because new C compilers
push si ; use them for register variables
push ds
push es
pushf
;-------get the source address-------------
mov si,a1[bp]
mov bx,si
mov cl,4 ; shift to extract segment
shr bx,cl
add bx,a1+2[bp] ; normalized source segment
;-------get the destination address--------
mov di,a2[bp]
mov dx,di
mov cl,4 ; shift to extract segment
shr dx,cl
add dx,a2+2[bp] ; normalized destination segment
mov ax,0fh
and si,ax ; source pointer
and di,ax ; destination pointer
cld ; set up for auto increment
mov ds,bx ; source segment
mov es,dx ;destination segment
mov ah,BLKCNT ; number of blocks to move
;-------COPY A BLOCK----------------------------------------------
;
; The buffer is copied to the display memory in blocks. Each block
; is copied in two parts. First, a chunk of words (characters and
; attributes) is copied during the vertical retrace period and then
; individual words are copied during the horizontal retrace periods
; of the normal screen update period. The display is not blanked.
;-----------------------------------------------------------------
copy_block:
;-------copy character/attribute words during vertical retrace----
mov cx,WRDCNT1 ; number of words to copy
mov dx,VSTAT ; c/g adapter status register
wait_vert_refresh:
in al,dx ; read status
test al,VRTRCE ; test vertical retrace bit
jnz wait_vert_refresh ; loop until in a refresh period
wait_vert_retrace:
in al,dx ; read status
test al,VRTRCE ; test vertical retrace bit
jz wait_vert_retrace ; loop until retrace starts
rep movsw ; move a block of char/attr words
;-------copy single bytes during horizontal retrace periods-------
mov cx,BYTECNT ; number of bytes to copy
cmp cx,0 ; anything to copy?
jz short bypass_horiz ; no bypass horiz. period updates
mov dx,VSTAT ; read c/g adapter status register
wait_horiz_refresh:
in al,dx
test al,HRTRCE ; test horizontal retrace bit
jnz wait_horiz_refresh ; loop until not in a retrace period
cli ; can't tolerate an interupt here
wait_horiz_retrace:
in al,dx
test al,HRTRCE ; test horizontal retrace bit
jz wait_horiz_retrace ; loop until retrace starts
movsb ; copy a byte
sti ; interupts OK now
loop wait_horiz_refresh
bypass_horiz:
;-------see if all rows have been copied-------------------
dec ah ; reduce the block count
cmp ah,0 ; done?
jnz short copy_block ; no - do it again
;-------clean up and return to caller----------------------
popf ; yes - restore flags...
pop es
pop ds
pop si
pop di
pop bp
ret
_cpblk endp
_TEXT ends
end